$(function(){
    list();
    $('.edit').click(function(){
        let id=$(this).attr('ids');
        layOpen('设置','500px','400px','./edit.html?id='+id);
    })

    $('.detail').click(function(){
        let title = $(this).attr('title');
        layOpen('详情','800px','700px','./detail.html?title='+title);
    })
});


function list(){
    let res = AjaxForm('admin/TranList','get');
    let data = res.list;
    let html = '';
    for (let i=0;i<=data.length-1;i++){
        html +=
            "<tr class=\"table-content\">\n" +
            "<td style='width: 28px;font-size: 20px'>"+data[i].title+"</td>" +
            "<td style='width: 70px'>"+data[i].num+"</td>" +
            "<td class='td'>"+data[i].buy_1+"</td>" +
            "<td class='td'>"+data[i].b1_num+"</td>"+
            "<td class='td'>"+data[i].buy_2+"</td>" +
            "<td class='td'>"+
            "<a class='detail layui-btn layui-btn-mini layui-btn-danger edit' ids='"+data[i].uid+"'>设置</a>"+
            "<a class='detail layui-btn layui-btn-mini layui-btn-disabled detail' title='"+data[i].title+"'>详情</a>"+
            "</td>"+
            "</tr>"
    }
    let ref = '目前持有金:0';
    if(res.money)ref ='目前持有金:'+res.money
    $('#btn-add').text(ref);
    $('#data-table').html(html);
}